package exo1.thread;

public class FirstThread  extends Thread{

	private boolean asc;
	private long wait=400;
	public FirstThread(boolean asc) {
		this.asc=asc;
		setDaemon(true);
		start();
	}
	@Override
	public void run() {
		super.run();
		if(asc==true){
//			while(true)
			writeAscNumber();
		}else{
//			while(true)
			writeDescNumber();
		}
	}
	private void writeDescNumber() {
		for(int i=0;i<100;i++){
			System.out.println("Asc:"+i);
			try {
				Thread.sleep(wait);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
			
	}
	private void writeAscNumber() {
		for(int i=99;i>=0;i--){
			System.out.println("Desc:"+i);
			try {
				Thread.sleep(wait);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	public static void main(String[] args) {
		FirstThread firstThread1=new FirstThread(true);
		FirstThread firstThread2=new FirstThread(false);
	}
}
